package com.bxd.baodan.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.bxd.baodan.R;
import com.bxd.baodan.adapter.CommonAdapter;
import com.bxd.baodan.adapter.ViewHolder;
import com.bxd.baodan.item.SortBean;

import java.util.ArrayList;
import java.util.List;

public class TestActivity extends Activity {

ListView lv;
TextView tv;
CommonAdapter<SortBean>adapter;
List<SortBean> beans = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_1);
    lv =   findViewById(R.id.listview);
    tv =   findViewById(R.id.test);
    tv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            beans.get(0).code = 200;
            adapter.notifyDataSetChanged();
        }
    });


        for (int i = 0; i < 5; i++) {
            SortBean bean = new SortBean();
            bean.code = i;
            bean.msg = "消息" + i;
            beans.add(bean);
        }


   adapter = new CommonAdapter<SortBean>(this,beans,android.R.layout.simple_expandable_list_item_1) {
       @Override
       public void convert(ViewHolder holder, SortBean item) {
          TextView tv = holder.getView(android.R.id.text1);
          tv.setText(item.code +"");
       }
   };

        lv.setAdapter(adapter);


    }

}
